import React from 'react'
import {Link} from 'react-router'
import Action from '../../action/action'
import Store from '../../store/store'
import ReactMixin from 'react-mixin'
import Reflux from 'reflux'

import './productList.less'

export default class ProductList extends React.Component{
    constructor(props){
        super(props);
        this.state = {}
    }
    getProductItem(i){
        Action.getProductItem(i)
    }
    render(){
        let {item} = this.props;
        let list = [];
        item.map((item,i)=>{
            list.push(
                <li key={i}>
                    <Link to={`/details?index=${i}` } style={{backgroundImage: `url(${item.url})`}} onClick={this.getProductItem.bind(this,i)}> </Link>
                    <p>
                        {item.shareF > 0 ? <i className="iconfont icon-fan"></i> : null}
                        {item.text}
                    </p>
                    <div>
                        <span>￥{item.originalPrice}</span>
                        <label>￥{item.presentPrice}</label>
                    </div>

                </li>
            )
        });
        return(
            <ul className="productList">
                {list}
            </ul>
        )
    }
}
ReactMixin.onClass(ProductList,Reflux.connect(Store));
